<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>二手书交易平台 - 商家首页</title>
    <link href="https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap" rel="stylesheet">
    <style>
        body {
            background: linear-gradient(120deg, #a1c4fd 0%, #c2e9fb 100%);
            font-family: 'Roboto', sans-serif;
            min-height: 100vh;
            margin: 0;
        }
        .layout {
            display: flex;
            min-height: 100vh;
        }
        .sidebar {
            width: 210px;
            background: #fff;
            box-shadow: 2px 0 16px rgba(0,0,0,0.07);
            display: flex;
            flex-direction: column;
            padding: 32px 0 0 0;
        }
        .sidebar-title {
            font-size: 1.3rem;
            font-weight: 700;
            color: #2d3a4b;
            text-align: center;
            margin-bottom: 36px;
        }
        .nav {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .nav a {
            display: block;
            padding: 12px 32px;
            color: #4a5a6a;
            text-decoration: none;
            font-size: 1.08rem;
            border-left: 4px solid transparent;
            transition: background 0.2s, color 0.2s, border-color 0.2s;
        }
        .nav a.active, .nav a:hover {
            background: #eaf3ff;
            color: #3478f6;
            border-left: 4px solid #7eb6ff;
        }
        .content {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .home-container {
            background: #fff;
            padding: 48px 48px 40px 48px;
            border-radius: 16px;
            box-shadow: 0 8px 32px rgba(0,0,0,0.12);
            width: 420px;
            max-width: 95vw;
            text-align: center;
        }
        .home-title {
            font-size: 2rem;
            font-weight: 700;
            color: #2d3a4b;
            margin-bottom: 16px;
        }
        .home-welcome {
            color: #6c7a89;
            font-size: 1.1rem;
            margin-bottom: 32px;
        }
        .logout-btn {
            margin: 32px 24px 0 24px;
            padding: 12px 0;
            width: calc(100% - 48px);
            background: linear-gradient(90deg, #ff6b6b 0%, #ffb36b 100%);
            color: #fff;
            font-weight: 700;
            border: none;
            border-radius: 8px;
            font-size: 1.08rem;
            cursor: pointer;
            transition: background 0.2s;
        }
        .logout-btn:hover {
            background: linear-gradient(90deg, #ffb36b 0%, #ff6b6b 100%);
        }
        .home-main {
            width: 100%;
            max-width: 900px;
            margin: 0 auto;
            display: flex;
            flex-direction: column;
            gap: 32px;
        }
        .banner {
            display: flex;
            align-items: center;
            background: linear-gradient(90deg, #a1c4fd 0%, #c2e9fb 100%);
            border-radius: 16px;
            padding: 32px 36px 32px 32px;
            box-shadow: 0 4px 24px rgba(120,160,255,0.10);
            gap: 32px;
        }
        .banner-text {
            flex: 1;
        }
        .banner-title {
            font-size: 1.6rem;
            font-weight: 700;
            color: #2d3a4b;
            margin-bottom: 10px;
        }
        .banner-desc {
            color: #4a5a6a;
            font-size: 1.08rem;
        }
        .banner-img {
            width: 90px;
            height: 90px;
            border-radius: 16px;
            background: #fff;
            box-shadow: 0 2px 12px rgba(120,160,255,0.10);
        }
        .overview {
            display: flex;
            gap: 24px;
            justify-content: space-between;
        }
        .overview-card {
            flex: 1;
            background: #f5f8fa;
            border-radius: 12px;
            padding: 24px 0 18px 0;
            text-align: center;
            box-shadow: 0 2px 8px rgba(120,160,255,0.07);
        }
        .overview-title {
            color: #6c7a89;
            font-size: 1.05rem;
            margin-bottom: 8px;
        }
        .overview-value {
            font-size: 2rem;
            font-weight: 700;
            color: #3478f6;
        }
        .quick-actions {
            display: flex;
            gap: 32px;
            justify-content: space-between;
            margin: 0 0 8px 0;
        }
        .quick-action {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background: linear-gradient(90deg, #7eb6ff 0%, #5eaefd 100%);
            color: #fff;
            border-radius: 14px;
            padding: 28px 0 20px 0;
            font-size: 1.15rem;
            font-weight: 700;
            text-decoration: none;
            box-shadow: 0 2px 12px rgba(120,160,255,0.10);
            transition: background 0.2s, box-shadow 0.2s;
        }
        .quick-action:hover {
            background: linear-gradient(90deg, #5eaefd 0%, #7eb6ff 100%);
            box-shadow: 0 4px 16px rgba(80,120,255,0.13);
        }
        .quick-icon {
            font-size: 2.2rem;
            margin-bottom: 10px;
        }
        .notice-bar {
            background: #fffbe6;
            color: #b47d00;
            border-radius: 8px;
            padding: 14px 22px;
            font-size: 1.05rem;
            box-shadow: 0 2px 8px rgba(255,200,80,0.07);
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .notice-title {
            font-weight: 700;
        }
    </style>
</head>
<body>
    <div class="layout">
        <aside class="sidebar">
            <div class="sidebar-title">商家中心</div>
            <nav class="nav">
                <a href="merchant_home.html" class="active">首页</a>
                <a href="merchant_books.html">书籍管理</a>
                <a href="merchant_orders.html">订单处理</a>
                <a href="merchant_add_book.html">发布新书</a>
                <a href="merchant_profile.html">个人信息</a>
            </nav>
            <button id="logoutBtn" class="logout-btn">退出登录</button>
        </aside>
        <main class="content">
            <div class="home-main">
                <div class="banner">
                    <div class="banner-text">
                        <div class="banner-title">欢迎来到二手书交易平台商家中心！</div>
                        <div class="banner-desc">高效管理您的二手书，轻松处理订单，助力生意增长。</div>
                    </div>
                    <img class="banner-img" src="https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/72x72/1f4da.png" alt="banner">
                </div>
                <div class="overview">
                    <div class="overview-card">
                        <div class="overview-title">在售书籍</div>
                        <div class="overview-value" id="bookCount">-</div>
                    </div>
                    <div class="overview-card">
                        <div class="overview-title">待发货订单</div>
                        <div class="overview-value" id="orderCount">-</div>
                    </div>
                    <div class="overview-card">
                        <div class="overview-title">本月销售额</div>
                        <div class="overview-value" id="totalPrice">-</div>
                    </div>
                </div>
                <div class="quick-actions">
                    <a href="merchant_add_book.html" class="quick-action">
                        <span class="quick-icon">📚</span>
                        <span>发布新书</span>
                    </a>
                    <a href="merchant_books.html" class="quick-action">
                        <span class="quick-icon">📖</span>
                        <span>管理书籍</span>
                    </a>
                    <a href="merchant_orders.html" class="quick-action">
                        <span class="quick-icon">📝</span>
                        <span>订单处理</span>
                    </a>
                </div>
                <div class="notice-bar">
                    <span class="notice-title">公告：</span>
                    <span>平台将于本月25日凌晨进行系统维护，请提前处理重要订单。</span>
                </div>
            </div>
        </main>
    </div>
    <script type="module">
        import { API_BASE_URL } from './api_config.js';
        // 获取商家ID
        const userInfo = JSON.parse(localStorage.getItem('userInfo') || '{}');
        const userId = userInfo.userId;
        if (!userId) {
            alert('未检测到商家身份，请重新登录');
            window.location.href = 'login.html';
        }
        // 获取首页数据
        fetch(`${API_BASE_URL}/userAccount/home/${userId}`)
            .then(res => res.json())
            .then(data => {
                if (data.success && data.code === 200) {
                    document.getElementById('bookCount').textContent = data.data.bookCount;
                    document.getElementById('orderCount').textContent = data.data.orderCount;
                    document.getElementById('totalPrice').textContent = '￥' + data.data.totalPrice.toFixed(2);
                }
            });
        // 退出登录
        document.getElementById('logoutBtn').onclick = function() {
            localStorage.removeItem('userInfo');
            window.location.href = 'login.html';
        };
    </script>
</body>
</html> 